ActiveReports 8 > ActiveReports User Guide > How To > Section Report How To > Add Bookmarks |
In a section report, you can display bookmarks and nested bookmarks in the viewer's table of contents for fields, groups, and subreports. You can also add special bookmarks at run time.
To set up basic bookmarks
The following example shows what the code for the method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event. |
Copy Code
|
---|---|
Me.Detail1.AddBookmark(textBox1.text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event. |
Copy Code
|
---|---|
detail.AddBookmark(textBox1.Text); |
To set up leveled or nested bookmarks
The following example shows what the code to set up leveled or nested Bookmarks looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event. |
Copy Code
|
---|---|
Me.Detail1.AddBookmark(txtCustomerID.Text + "\" + txtContactName.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event. |
Copy Code
|
---|---|
detail.AddBookmark(txtCustomerID.Text + "\\" + txtContactName.Text); |
To nest grandchild bookmarks and use bookmarks in grouping
The following example shows what the code for the detail section looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail_Format event. |
Copy Code
|
---|---|
Me.Detail1.AddBookmark(txtCity.Text + "\" + txtCustomerID.Text + "\" + txtContactName.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail_Format event. |
Copy Code
|
---|---|
this.detail.AddBookmark(txtCity.Text + "\\" + txtCustomerID.Text + "\\" + txtContactName.Text); |
The following example shows what the code for the group header looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Group Header Format event. |
Copy Code
|
---|---|
Me.GroupHeader1.AddBookmark(txtCity.Text) |
To write the code in C#
C# code. Paste INSIDE the Group Header Format event. |
Copy Code
|
---|---|
this.groupHeader1.AddBookmark(txtCity.Text); |
To combine parent report and subreport bookmarks
The following example shows what the code for the method looks like for the main report.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event of the main report. |
Copy Code
|
---|---|
Me.Detail1.AddBookmark(txtCustomerID.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event of the main report. |
Copy Code
|
---|---|
detail1.AddBookmark(txtCustomerID.Text); |
The following example shows what the code for the method looks like for the subreport.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event of the subreport. |
Copy Code
|
---|---|
Me.Detail1.AddBookmark(CType(Me.ParentReport.Sections("Detail1").Controls("txtCustomerID"), TextBox).Text + "\" + Me.txtContactName.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event of the subreport. |
Copy Code
|
---|---|
this.detail1.AddBookmark(((TextBox)(this.ParentReport.Sections["Detail1"].Controls["txtCustomerID"])).Text + "\\" + this.txtContactName.Text); |
To add special bookmarks at run time
To create and add special bookmarks to the bookmarks collection at run time, add the bookmarks to the report document's pages collection.
Caution: Remember that the page collection does not exist until the report runs, so use this code in the ReportEnd event or in form code after the report has run. |
To write the code in Visual Basic.NET
The following example shows what the code for the method looks like.
Visual Basic.NET code. Paste INSIDE the ReportEnd event. |
Copy Code
|
---|---|
Me.Document.Pages(0).AddBookmark("New Bookmark", 1) |
To write the code in C#
C# code. Paste INSIDE the ReportEnd event. |
Copy Code
|
---|---|
this.Document.Pages[0].AddBookmark("New Bookmark", 1); |